<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>User Center</title>
	<link rel="stylesheet" href="../css/xingchao.css">
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../js/layer/layer.js"></script>
    <script type="text/javascript" src="../js/jquery.md5.js"></script>
    <style type="text/css">
		#chargeBtn:hover{
			cursor: pointer;
		}
    </style>
</head>
<body style="background: #EFEFEF; ">

<!--  
	头部
-->
<div  id="usercenter" style="">
<div class="head">
	<div class="w" style="height:50px;">
		<a href="index.html">
			<img src="../images/logo.png" alt="" width="150px;">
		</a>
		<ul class="nav r">
	       <li>
	            <a href="index.html">USources</a>
	            <sub class="sub1"></sub>
	        </li>
	        <li>
	            <a href="ziyuan.html">Search</a>
	            <sub class="sub1"></sub>
	        </li>
	        <li>
	            <a href="jiaocheng.html">Tutorial</a>
	            <sub class="sub1"></sub>
	        </li>
	        <li>
	            <a href="biaozhun.html">KnowledgeGraph</a>
	            <sub class="sub1"></sub>
	        </li>
	        <li>
	            <a href="page.html">AboutUs</a>
	            <sub class="sub1"></sub>
	        </li>
	        <li>
	            <a href="user.html" id="user-box">UserCenter</a>|<a href="user.html?action=out">Logout</a>
	            <sub class="sub1"></sub>
	        </li>
	        <li id="langBox">
                <a href="../bill.html" data-lang='zh-CN'>中</a>&nbsp;|
                <a href="#" data-lang="en-US">EN</a>
                <sub class="sub1"></sub>
            </li>
		</ul>
	</div>
</div>

<div class="main w">
<!--  
	当前位置
-->
	<div class="position">
		Current Page：<a href="">User Center</a> > <a href="">User Bill</a>
	</div>
<!--  
	会员信息
-->
	<div class="user">
		<div class="user_left l">
			<ul class="left_c">
				<div class="left_t">Resource Management</div>
                <li><a href="agent.html">My Collection</a></li>
                <li><a href="uploads.html" >My Uploads</a>
                <li><a href="userOrder.html" >My Orders</a></li>
				
				<br><div class="left_t">Account Management</div>
                <li><a href="bill.html" style="color: #5fadfc;">My balance</a></li>
                <li><a href="editpwd.html">Change Password</a></li>
			</ul>
		</div>
		<div class="user_right r">
			<div class="right_t">My balance</div>
			<div class="right_c">
				<div style="height: 55px;line-height: 55px;">
					<span class="l" style="width: 200px;">Zombie (money unit)：</span>
					<label id="zybRemainLabel">0</label>
				</div>
				<div>
					<input type="text" id="inputCoin" placeholder="Value to Charge" class="i1" style="width:30%"/>
					<input type="button" class="i2" id="chargeBtn" value="Charge" style="width:15%" onclick="charge()">
					<label>（1 Zombie = 1 RMB）</label>
				</div>
				<div id="chargeListDiv" style="display: none;margin-top: 50px">
					<p>Charge Records:</p><br/>
					<table class="table table-hover">
						<thead>
							<tr>
								<th>No.</th>
								<th>Order_id</th>
								<th>Value(Zombie)</th>
								<th>Date</th>
							</tr>
						</thead>
						<tbody id="chargeListTb"></tbody>
					</table>
				</div>
				<div id="incomeLogListDiv" style="display: none;margin-top: 50px">
					<p>Income Records:</p><br/>
					<table class="table table-hover">
						<thead>
							<tr>
								<th>No.</th>
								<th>Zombie Earned</th>
								<th>purchased datakey</th>
								<th>buyer</th>
								<th>Date</th>
							</tr>
						</thead>
						<tbody id="incomeLogListTb"></tbody>
					</table>
				</div>
			</div>
		</div>
	</div>
	<div class="clear"></div>
</div>
<!--  
	底部
-->
<div class="copyright">
	Copyright © 2016-2017 Semantic (Shanghai) Information Technology Co., Ltd. All rights reserved.
 &nbsp;&nbsp;&nbsp;
</div>
</div>
</body>
</html>
<script type="text/javascript" src="../js/App.min.js"></script>
<script type="text/javascript">
	(function(){
		$.ajax({
		url:"http://www.usources.cn/api/user/ZYBRemain",
		type:'GET',
		xhrFields: {
			withCredentials: true
		},
		crossDomain:true,
		data:{},
		success:function(data){
			if(data.code == 1003){
				layer.open({
					content: "您尚未登录"
					,btn: ['确认']
					,yes: function(index, layero){
						location.href="login.html";
					}
				});
			}else{
				var zybRemain = data.data.info.zybRemain?data.data.info.zybRemain:0;
				$("#zybRemainLabel").html(zybRemain);
			}
		},
		error:function(error){
			console.log(error);
			layer.msg('服务异常,请稍后重试',{icon:2});
		},dataType:'json'});

		$.ajax({
		url:"http://www.usources.cn/api/user/chargeOrders",
		type:'GET',
		xhrFields: {
			withCredentials: true
		},
		crossDomain:true,
		data:{},
		success:function(data){
			if(data.code == 1003){
				layer.open({
					content: "您尚未登录"
					,btn: ['确认']
					,yes: function(index, layero){
						location.href="login.html";
					}
				});
			}else{
				var chargeList = data.data.list
				if(chargeList.length > 0){
					var str;
					for(var i = 0;i<chargeList.length;i++){
						str += "<tr><td>"+(i+1)+"</td><td>"+chargeList[i].invoiceId+
						"</td><td>"+chargeList[i].amount+"</td><td>"+chargeList[i].createdTime+"</td></tr>"
					}
					$("#chargeListTb").append(str);
					$("#chargeListDiv").css("display","");
				}
			}
		},
		error:function(error){
			console.log(error);
			layer.msg('服务异常,请稍后重试',{icon:2});
		},dataType:'json'});

		$.ajax({
		url:"http://www.usources.cn/api/user/incomeLog",
		type:'GET',
		xhrFields: {
			withCredentials: true
		},
		crossDomain:true,
		data:{},
		success:function(data){
			if(data.code == 1003){
				layer.open({
					content: "您尚未登录"
					,btn: ['确认']
					,yes: function(index, layero){
						location.href="login.html";
					}
				});
			}else{
				var chargeList = data.data.list
				if(chargeList.length > 0){
					var str;
					for(var i = 0;i<chargeList.length;i++){
						str += "<tr><td>"+(i+1)+"</td><td>"+chargeList[i].incomeAmount+
						"</td><td>"+chargeList[i].fromDataKey+"</td><td>"+chargeList[i].fromUserName+
						"</td><td>"+chargeList[i].createdTime+"</td></tr>"
					}
					$("#incomeLogListTb").append(str);
					$("#incomeLogListDiv").css("display","");
				}
			}
		},
		error:function(error){
			console.log(error);
			layer.msg('服务异常,请稍后重试',{icon:2});
		},dataType:'json'});
	})()
	function charge(){
		var inputCoin = $("#inputCoin").val();
		var reg = /^[0-9]+$/;
		if(!inputCoin || !reg.test(inputCoin)){
			alert("请输入正确的充值金额(只能是整数)");
			return;
		}
		window.location.href="chargeOrder.html?amount="+inputCoin;
	}
</script>

